#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'teffy'

'''
@created on 17-11-9
@poject:python-shoot-game
@author:teffy
'''

import pygame
from pygame.sprite import Sprite

class Bullet(Sprite):

    def __init__(self,settings,screen,ship):
        super(Bullet,self).__init__()
        self.screen = screen

        self.rect = pygame.Rect(0,0,settings.bullet_width,settings.bullet_height)
        self.rect.centerx = ship.rect.centerx
        self.rect.top = ship.rect.top

        self.y = float(self.rect.y)
        self.color = settings.bullet_color
        self.speed_factor = settings.bullet_speed_factor

    def update(self, *args):
        self.y -= self.speed_factor
        self.rect.y = self.y

    def draw_bullet(self):
        pygame.draw.rect(self.screen,self.color,self.rect)